package cn.sylinx.hbatis.ext.model;

import java.io.Serializable;

@SuppressWarnings("serial")
public class GenericModel<PK extends Serializable> extends Model {

	/**
	 * 主键
	 */
	private PK id;

	public PK getId() {
		return id;
	}

	public void setId(PK id) {
		this.id = id;
	}

	@Override
	public int hashCode() {
		if (getId() == null)
			return 0;
		return getId().hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		if (this.getClass() != obj.getClass()) {
			return false;
		}

		return this.hashCode() == obj.hashCode();
	}

}
